Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve enum parsing from JSON #82

Merged
merged 1 commit into from
Aug 22, 2023
Merged

Conversation

sebastiangrimberg
Copy link
Contributor

Previously every enum defined in configfile.hpp had a *_INVALID option because the behavior of the NLOHMANN_JSON_SERIALIZE_ENUM macro's from_json was to assign to the first enum in the list if no matching value was found in the provided map. This PR writes adds a custom from_json function which throws an error in this case, since this was always what we wanted to do, and allows us to remove these extraneous *_INVALID enum options from the code.

@sebastiangrimberg sebastiangrimberg added the minor A minor issue or improvement label Aug 11, 2023
@sebastiangrimberg sebastiangrimberg force-pushed the hughcars/lumped-port-orientation-dev branch from f632ee9 to b9c26d7 Compare August 22, 2023 17:20
@sebastiangrimberg sebastiangrimberg marked this pull request as ready for review August 22, 2023 18:19
Base automatically changed from hughcars/lumped-port-orientation-dev to main August 22, 2023 22:00
… and eliminate need for INVALID enums throughout the code
@sebastiangrimberg sebastiangrimberg merged commit c5e4203 into main Aug 22, 2023
@sebastiangrimberg sebastiangrimberg deleted the sjg/json-enum-parsing branch August 22, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor A minor issue or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants